import React, { Component } from 'react';
import { WingBlank, WhiteSpace, Toast } from 'antd-mobile';
import { hashHistory } from 'react-router';
import 'common/components/bookItem.less';

class BookItem extends Component{

	gotoDetail = (book) => {
		if(book && book._id && book._id != ""){
			hashHistory.push("/bookDetail/"+book._id);
		}else{
			Toast.info("书籍不存在", 1.5);
		}
	}

	render(){
		const { book } = this.props;
		let bookImage = "http://statics.zhuishushenqi.com"+book.cover;

		return(
			<div className="book_item">
				<div className="book_item_left">
					<img src={bookImage} onClick={() => this.gotoDetail(book)}/>
				</div>
				<div className="book_item_right">
					<span>{book.title}</span>
					<span className="book_item_author">{book.author}</span>
					<span className="book_item_desc" onClick={() => this.gotoDetail(book)}>
						{book.shortIntro}
					</span>
				</div>
			</div>
		)
	}
}

export default BookItem;